//提交form，把得到的数据放在指定的ID上.
function ajaxFormRequest(datastr) {
	eval("var obj = "+datastr+";"); 
	if (obj.id == null)
  		obj.id = "paginationResult";
    $j("#"+obj.id).html("<div align=\"center\"> 查询中........</div>");
	ajaxHtmlRequest(obj);
}

//提交form，把得到的数据放在指定的ID上.
function ajaxHtmlRequest(obj) {
	disableBtn();
	var methodType = (obj.params==null?"GET":"POST");
	var data = obj.params;
	var ajaxUrl = parseUrl(obj.url); 
	$j.ajax({
		type: methodType,
		url: ajaxUrl,
		dataType:	'text',
		cache:false,
		data:data,
		success: function(data, textStatus, XMLHttpRequest){
		    $j("#"+obj.id).html(data);
			enableBtn();
		},
		error: function(XMLHttpRequest, textStatus, errorThrown){
			alert("error");
			enableBtn();
		}
	});
}

function ajaxRequest(obj){
	var dataType = (obj.dataType==null?"text":obj.dataType);
	var cache = (obj.cache==null?false:obj.cache);
	var async = (obj.async==null?true:obj.async);
	var data = (obj.data==null?null:obj.data);
	var methodType = (data==null?"GET":"POST");
	var errorFunc = (obj.error==null?function(XMLHttpRequest, textStatus, errorThrown){alert('e2');}:obj.error);
	$j.ajax({
		type: methodType,
		url: obj.url,
		dataType: dataType,
		cache:cache,
		data:data,
		success: obj.success,
		error: errorFunc
	});	
}

//将显示分页的结果
function pagination(obj) {
  if (obj.id == null||obj.id=="null"){
     obj.id = "paginationResult";
  }
  $j("#"+obj.id).html("<div align=\"center\"> 查询中........</div>");
  ajaxHtmlRequest(obj);
}

//分页时,请求到第几页数据
function goPage(dataObject) {
   var page=1;
   if (document.getElementById('gopage').value != null &&document.getElementById('gopage').value != ''){
      page=document.getElementById('gopage').value;
   }
   //dataObject.url=dataObject.url+'&pageNum='+page;
   dataObject.params=dataObject.params+'&pageNum='+page;
   pagination(dataObject);
}

function parseUrl(url){
	return url;
}

function disableBtn(){
	var oBtns = document.getElementsByName("BTN_QRY");
	if(oBtns != null && oBtns.length > 0){
		for(var i=0; i<oBtns.length; i++){
			oBtns[i].disabled = true;
		}
	}
}

function enableBtn(){
	var oBtns = document.getElementsByName("BTN_QRY");
	if(oBtns != null && oBtns.length > 0){
		for(var i=0; i<oBtns.length; i++){
			oBtns[i].disabled = false;
		}
	}
}